<?php
$title="添加新推荐";
$css="AddRecommend.css";
include_once 'common/AdminTop.php';
include_once 'authentic.php';
include_once '../Class/DB.php';
$db=new DB();
$newPid=$_POST["good_id"];
$newPic=$_POST["picurl"];
if(!isset($newPid))
{

}else if ($newPid=="")
{
	?>
	<script language="JavaScript">
	alert("推荐商品ID不能为空！");
	window.location.href="AddRecommend.php";
	</script>	
	<?php
	exit();
}else 
{
	$theNewProduct=$db->get_pid_product($newPid);
	if(!isset($theNewProduct[0]))
	{
	?>
	<script language="JavaScript">
	alert("推荐商品ID不存在！");
	window.location.href="AddRecommend.php";
	</script>	
	<?php
	exit();
	}
}

if(!isset($newPic))
{
	
}
else if($newPic=="")
{
	?>
	<script language="JavaScript">
	alert("横幅位置不能为空!");
	window.location.href="AddRecommend.php";
	</script>	
	<?php
	exit();
}else
{
	$newPic='../image/hot/'.$newPic;
}

if(isset($_POST["good_id"]))//说明管理员按了按钮
{
	$db->Add_recommend($newPid,$newPic);
	?>
	<script language="JavaScript">
	window.location.href="others.php";
	</script>	
	<?php
	exit();
}
?>
<div class="block_context" id="modify_block" align="center">
<p style="color:red">推荐商品详细信息</p>
				<form action="AddRecommend.php" method="post">
					<table>
						<tr>
							<th class="t1" >
							</th>
							<th class="t2">
							</th>	
						</tr>						
						<tr>
							<td style="text-align:right;">
							<b>推荐商品ID:</b>
							</td>
							<td style="padding-left:16px;text-align:left;"><input type="text" style="width:80px;" name="good_id"  value=""/></td>
						</tr>
						<tr>
						<td style="text-align: right;">
							<b>横幅位置:</b>
						</td>
						<td style="padding-left:16px;text-align: left;">
						<input type="file" style="color:red;" name="picurl"  value=""/>		
						</td>
						</tr>
						</table>
						<p><input type="submit" value="添加" />
						</p>
				</form>
			</div>
<?php 
include_once 'common/AdminTail.php';
?>